<?php

namespace app\common\model;

use org\UUID;
use think\Model;

class User extends Model
{
    protected $insert = ['create_time', 'user_uuid'];

    /**
     * 创建时间
     * @return bool|string
     */
    protected function setCreateTimeAttr()
    {
        return date('Y-m-d H:i:s');
    }

    protected function setUserUuidAttr()
    {
        return UUID::v4();
    }

    public function getUserInfoById($id,$field = 'username'){
        $info = $this->find($id);
        if(!empty($info)){
            return $info[$field];
        }
        return $id;
    }
}